<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<base th:href="@{/}">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<th:block th:include ="commHeaderInclude::commHead"></th:block>
<title>新增查询</title>
	<style>
		.form{}
		.form .error{ color: #f30; margin-left: 20px; display: none;}
		input.disabled{
			background-color: #f6f6f6 !important;
			color: #999;
		}
		.labelDisabled{
			color: #BBBBBB !important;
		}
	</style>
</head>
<body class="ht">
<th:block th:include="commHeaderInclude::loading"></th:block>
	<div class="tabTitle" th:if="*{from=='payLog'}"><span><i class="mdi mdi-menu-up"></i>医保结算信息查询</span></div>
	<div class="content-wrapper">
		<form name="form" id="form" class="form" method="post" th:object="${dto}" novalidate onsubmit="ht.loading.open();">
			<input type="hidden" name="token" th:value="${session.token}">
			<input type="hidden" name="itfType" th:value="*{itfType}" >
			<div class="alert alert-warning"><i class=" mdi mdi-alert-circle"></i>仅支持查询存在有效授权的医保定点机构；如数据异常，请联系平台客服或数据来源机构</div>
			<div class="card mb-3">
				<div class="card-body">
					<!--<h4 class="card-title"></h4>-->
					<div class="module">
						<table cellpadding="0" cellspacing="0" class="vTable">
							<tbody>
                                <tr>
                                    <th><span class="required">*</span>医保定点机构名称</th>
                                    <td><input type="text" class="disabled" required name="targetOrgName" th:value="*{@util.fStr(targetOrgName)}" onfocus="this.blur();" style="width: 410px;color:transparent;text-shadow:0 0 0 #666;" autocomplete="no" /><a class="btn btn-outline-primary btn-sm ml-2" role="openFrameWindow" th:href="@{/bank/payLog/hospitalSelector}" target="_top" th:if="*{from=='payLog'}">选择</a><span class="error" th:errors="*{targetOrgId}" th:if="*{#fields.hasErrors('targetOrgId')}"></span></td>
                                </tr>
								<tr class="limited">
									<th></th>
									<td><input type="text" class="disabled" required name="targetOrgId" th:value="*{targetOrgId}" readonly  style="width: 410px;color:transparent;text-shadow:0 0 0 #666;" autocomplete="no" /></td>
								</tr>
								<tr>
									<th><span class="required">*</span>统一社会信用代码</th>
									<td><input type="text" class="disabled" name="targetOrgCode" th:value="*{targetOrgCode}" onfocus="this.blur();"  style="width: 410px;color:transparent;text-shadow:0 0 0 #666;" autocomplete="no" /></td>
								</tr>
								<tr>
									<th><span class="required">*</span>授权书</th>
									<td><input type="text" class="disabled" required name="authNo" th:value="*{authNo}" onfocus="this.blur();"  style="width: 410px;color:transparent;text-shadow:0 0 0 #666;" autocomplete="no" /><a class="btn btn-outline-primary btn-sm ml-2 disabled" id="authSelectButton" target="_top" th:if="*{from=='payLog'}">选择</a><span class="error" th:errors="*{authId}" th:if="*{#fields.hasErrors('authId')}"></span></td>
								</tr>
								<tr class="limited">
									<th></th>
									<td><input type="text" name="authId" th:value="*{authId}" readonly /></td>
								</tr>
                                <tr>
                                    <th><span class="required">*</span>查询内容</th>
                                    <td>
										<span role="CheckboxGroup">
		                                    <input type="hidden" name="dataType" th:value="*{dataType}" role="CheckboxChecked" />
		                                    <input type="checkbox" name="dataType" id="dataType1" value="1"/>
		                                    <label for="dataType1" id="dataTypeLabel1">主体信息汇总表</label>
		                                    <input type="checkbox" name="dataType" id="dataType2" value="2"/>
		                                    <label for="dataType2" id="dataTypeLabel2">医保结算账户信息</label>
		                                    <input type="checkbox" name="dataType" id="dataType3" value="3"/>
		                                    <label for="dataType3">医保结算明细数据</label>
		                                </span>
                                    </td>
                                </tr>
								<tr id="payDate">
									<th>结算起止日期</th>
									<td>
										<li>
											<span><input class="ht-dateInput" style="width: 110px" type="date" name="payStartDate" th:value="*{payStartDate}" data-options="endSelector:'[name=payEndDate]'"/></span>
											<span class="ht_dateText d-inlineBlock">至</span>
											<span><input class="ht-dateInput" style="width: 110px" type="date" name="payEndDate" th:value="*{payEndDate}" data-options="startSelector:'[name=payStartDate]'"/></span>
											<span style="color: gray;">平台支持查询前年1月1日至今的结算数据，具体以当地主管机构为准。</span>
										</li>
									</td>
								</tr>
								<tr>
									<th class="label"><span class="required">*</span>查询原因</th>
									<td>
										<select name="queryReasonType" id="queryReasonType">
		                                    <option th:value="*{queryReasonType}" selected role="OptionSelected"></option>
											<option value="">未选择</option>
											<option value="1">交易前调查</option>
											<option value="2">交易中监测</option>
											<option value="3">交易后管理</option>
											<option value="4">破产事务管理</option>
											<option value="5">业务纠纷</option>
											<option value="6">其他合法目的</option>
										</select>
									</td>
								</tr>
								<tr id="queryReason">
									<th class="label">具体内容</th>
									<td><textarea type="text" required maxlength="200" name="queryReason" th:text="*{@util.fStr(queryReason)}" style="width: 400px;"></textarea>
										<span class="error" th:errors="*{queryReason}" th:if="*{#fields.hasErrors('queryReason')}"></span>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
			</div>

			<div class="row">
				<input class="btn btn-primary btn-lg" type="submit" value="申请查询" />
				<input class="btn btn-secondary btn-lg" type="button" value="取 消" onclick="parent.ht.closeAllFrameWindow()"/>
			</div>
		</form>
	</div>


	<div class="ht-dialog auto" role="autoOpenDialog">
		<div class="wrapper">
			<h4 class="title" th:text="${result.msg}">提示</h4>
			<a class="ht-closeButton">close</a>
			<div class="content">
				<ul th:if="${#fields.hasErrors('dto.*')}">
					<li th:each="err:${#fields.errors('dto.*')}" th:text="${err}"></li>
				</ul>
			</div>
		</div>
	</div>


</body>
<script>
$(function(){
	var mcp_pfm = '[[${dto.mcp_pfm}]]';
	var queryReasonType = '[[${dto.queryReasonType}]]';
	

	if(mcp_pfm != null && mcp_pfm != ""){
	 	if(mcp_pfm == '0'){
	 		 $("#dataType1").attr("disabled","disabled");
	 		 $("#dataType2").attr("disabled","disabled");
	 		 
			 $("#dataTypeLabel1").addClass("labelDisabled");
			 $("#dataTypeLabel2").addClass("labelDisabled");
	 	}
	}
	
	var dataType3checked = $("#dataType3").is(':checked');
	if(dataType3checked){
		$("#payDate").show();
	}else{
		$("#payDate").hide();
		$("[name=payStartDate]").val("");
		$("[name=payEndDate]").val("");
	}
	
	if(queryReasonType == '6'){
		$("#queryReason").show();
	}else{
		$("#queryReason").hide();
		$("[name=queryReason]").val("");
	}
	
});	
	
	
function setHospitalById(id){
    loadHospitalById(id);
}
var targetOrgId=$("[name=targetOrgId]").val();
if(targetOrgId!=""){
    $("#authSelectButton").removeClass("disabled");
}
function loadHospitalById(id){
    var options={
        url:baseUrl+"/bank/payLog/hospitalDetail?id="+id,
        success(res){
            //console.log(res);
            var vo=res.data;
            $("[name=targetOrgId]").val(vo.id);

            $("[name=targetOrgName]").val(vo.orgName);
            $("[name=targetOrgCode]").val(vo.orgCode);

            top.ht.closeAllFrameWindow()

			//$("#authSelectButton").prop("href","bank/payLog/authSelector?miOrgId="+vo.id+"&miOrgCode="+vo.orgCode);
            $("#authSelectButton").removeClass("disabled");

            //清空数据
            $("[name=authId]").val("");
            $("[name=authNo]").val("");
        },
        fail(err){
            //console.log(err)
        }
    };
    $.ajax(options)
}

$("#authSelectButton").unbind("click");
$("#authSelectButton").off("click");

$("#authSelectButton").on("click",function(event){
    var miOrgId=$("[name=targetOrgId]").val();
    var miOrgCode=$("[name=targetOrgCode]").val();
    if(miOrgId=="" || miOrgCode==""){
        return ;
	}
    var url=baseUrl+"/bank/payLog/authSelector?miOrgId="+miOrgId+"&miOrgCode="+miOrgCode;
    top.ht.openFrameWindow(url,"","");
})

$("#dataType3").on("click",function(event){
	var dataType3checked = $("#dataType3").is(':checked');
	var itfType = $("[name=itfType]").val();
	if(dataType3checked && !!itfType && itfType == '1'){
		$("#payDate").show();
	}else{
		$("#payDate").hide();
		$("[name=payStartDate]").val("");
		$("[name=payEndDate]").val("");
	}
})



$("#queryReasonType").on("change",function(event){
	var selectType = $("#queryReasonType option:selected").val();
	
	if(selectType == '6'){
		$("#queryReason").show();
	}else{
		$("#queryReason").hide();
		$("[name=queryReason]").val("");
	}
})


function setAuthById(id){
    loadAuthById(id);
}
function loadAuthById(id){
    var options={
        url:baseUrl+"/bank/payLog/authDetail?id="+id,
        success(res){
            //console.log(res);
			var vo=res.data;

            $("[name=authId]").val(vo.id);
            $("[name=authNo]").val(vo.authNo);
			if(vo.itfType != null && vo.itfType != ""){
				$("[name=itfType]").val(vo.itfType);
				if(vo.itfType == 0){
					$("[id=dataType1]").prop('checked', false);
					$("[id=dataType2]").prop('checked', false);
					$("[id=dataType1]").attr("disabled","disabled");
					$("[id=dataType2]").attr("disabled","disabled");
						 		 
					$("#dataTypeLabel1").addClass("labelDisabled");
					$("#dataTypeLabel2").addClass("labelDisabled");
					
					$("#payDate").hide();
					$("[name=payStartDate]").val("");
					$("[name=payEndDate]").val("");
				}else {
					$("[id=dataType1]").prop("disabled", false);
					$("[id=dataType2]").prop("disabled", false);
					$("#dataTypeLabel1").removeClass("labelDisabled");
					$("#dataTypeLabel2").removeClass("labelDisabled");
				}
			}
            top.ht.closeAllFrameWindow()
        },
        fail(err){
            //console.log(err)
        }
    };
    $.ajax(options)
}
top.setAuthById=setAuthById;
top.setHospitalById=setHospitalById;


var form=new HTMLTurbo.control.Form("#form");
form.ruleUrl=baseUrl+"/bank/payLog/createFormRule.json";
form.init()
</script>
</html>